I purchased a Drupal theme and the the support is...lacking. So I thought I'd try and tackle it myself. I'm relatively new to PHP programming, so please take it easy on me :)
The error I got was: Notice: Object of class Drupal\Core\Field\FieldItemList could not be converted to int in theme_css_alter()
Digging into the error, it came from the first line of code in this if statement:
if(isset($node->nid) && $node->nid == 90){
//do stuff
}
I did my research and found that its a PHP error when using the == operator, likely since $node->nid is being fetched as a string, and 90 is an integer, and it can't convert the nid on the fly.
Possible solutions I found while Googling were either making a 'getter' to fetch the nid as an integer (which sounds more complicated than necessary), using the === operator; and I'm guessing on my own that if I convert 90 to a string it would also work?
Now, doing a test run, === does stop the error from showing, but my research shows that === only works when both the value and type are equal, and given I'm comparing a string and an integer, I assume that it would always just be false then.
So...
When you compare a number with something else, the other thing is first converted to a number, and then these two numbers are compared. So a comparison like "90" == 90
does what you expect -- it's equivalent to 90 == 90
.
The problem you're having is that $node->nid
is not a string, it's an object of class Drupal\Core\Field\FieldItemList
. The class doesn't provide a method to convert this type to a number, so it's not able to perform the comparison.
However, it appears that this type has a method to convert to string. But PHP won't do a double conversion when performing the comparison. So you need to perform the object->string conversion explicitly, and then PHP will convert the string to an integer.
if (isset($node->nid) && (string)$node->nid == 90)
A string will not be equal to an integer. You need to check for the type too. That is why we use the triple equal sign ===. Consider the following code:
$integer = 90;
$string = "90";
echo($integer == $string); // prints 1 (true)
echo($integer === $string); // prints 0 (false)
You can test your own variables in this page.
Barmar is correct on why this if statement is failing; the comparison is working but $node->nid is not a string or an integer. I'm adding this answer as additional reference for the Drupal side of things.
As reference: https://drupal.stackexchange.com/questions/145823/how-do-i-get-the-current-node-id
Drupal 8 has changed the way to access nid values. Ultimately, the reason is that the parameter is upcasted to a full node object when you try to access it, so its neither a string or integer.
The correct way to do the comparison would be to use either $node->nid->value or $node->id(). Alternative ways to fetch the id as a value are in the link.